package com.gougou.service.impl;

import com.alicp.jetcache.anno.Cached;
import com.gougou.mapper.TbUserMapper;
import com.gougou.pojo.TbUser;
import com.gougou.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * Created by EX-ZHANZHENQIANG001 on 2018-04-18.
 */
@Service
public class UserServiceImpl implements UserService{


    @Autowired
    private TbUserMapper tbUserMapper;


    /**
     * 根据用户名获取用户信息
     * @return
     */
    @Override
    @Transactional
    @Cached(name="UserService.getUserByName", expire = 3600)
    public TbUser getUserByName(TbUser user) {
        return tbUserMapper.getUserByName(user);
    }


    @Override
    @Transactional
    @Cached(name="UserService.getUserbyName", expire = 3600)
    public TbUser getUserbyName(String userName) {
        return tbUserMapper.getUserByUserName(userName);
    }


    /**
     * 调用存储过程输入参数计算返回值
     * @param param
     * @return
     */
    @Override
    @Cached(name="UserService.pageAdd", expire = 3600)
    public String pageAdd(Map<String, String> param) {
        tbUserMapper.pageAdd(param);
        return String.valueOf(param.get("p3"));
    }

    /**
     * 新用户注册
     * @param tbUser
     */
    @Override
    public void registerUser(TbUser tbUser) {
        tbUserMapper.registerUser(tbUser);
    }

    /**
     * 根据用户ID获取用户信息
     * @param user
     * @return
     */
    @Override
    public TbUser getUserById(TbUser user) {

        return null;
    }

    /**
     * 新增、注册 用户信息
     * @param user
     * @return
     */
    @Override
    public boolean addUser(TbUser user) {

        return true;
    }

    /**
     * 根据用户ID删除用户
     * @param user
     * @return
     */
    @Override
    public boolean removeUserById(TbUser user) {

        return true;
    }
}
